//
// Created by Akashic on 2024/7/9.
//

#ifndef LINKMAP_H
#define LINKMAP_H

#include <stdio.h>
#include <stdlib.h>
#include "stdbool.h"
#include "linklist.h"



#ifdef __cplusplus
extern "C"
{
#endif


typedef struct LinkMap {
    LinkList *keyList;
    bool (*filter)(void *key1, void *key2);
    void (*freeKey) (void *key);
    void  (*freeData)(void *data);
} LinkMap;



typedef struct KeyNode{
    void *key;
    LinkList *data;
    void (*freeKey) (void *key);
}KeyNode;


void freeKeyNode(void *key);

LinkMap *createMap(void  (*freeKey)(void *key),
                   void  (*freeData)(void *data),
                   bool (*filter)(void *key1, void *key2));


void insert(LinkMap *linkMap, void *key, void *value);

LinkList *getList(LinkMap *linkMap, void *key);

void delKey(LinkMap *linkMap, void *key);

#ifdef __cplusplus
}
#endif

#endif //TEST_DEMO_LINKMAP_H
